//
//  SoundBookViewController.m
//  XMLY
//
//  Created by 曾杰 on 15/11/4.
//  Copyright © 2015年 曾杰. All rights reserved.
//

#import "SoundBookViewController.h"
#import "SoundBookCell.h"
#import "PKRequestManager.h"
#import "SoundBookModel.h"
#import "UIImageView+WebCache.h"
#import "BookListTableViewController.h"
#import "HACursor.h"
#import "BookRecommendTableViewController.h"
@interface SoundBookViewController ()
@property (nonatomic, strong) NSArray *items;
@property (nonatomic, strong) BookListTableViewController *bookListVC;
@property (nonatomic, strong) BookRecommendTableViewController *bookRecomVC;
@property (nonatomic, strong) UITableView *textView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) NSString *urlStr;
@property (nonatomic, strong) NSMutableArray *pageViews;
@end
@implementation SoundBookViewController


- (NSArray *)items {
    if (_items == nil) {
        _items = @[@"推荐", @"浪漫言情", @"恐怖悬疑", @"玄幻奇幻", @"历史军事", @"古言宫斗", @"探案推理", @"青春校园", @"都市生活", @"穿越架空", @"武侠仙侠",@"文学名著",@"官场商战",@"科幻游戏",@"诗词散文",@"社科经营",@"QQ阅读",@"读客图书",@"果麦文化",@"中信出版",@"博集天卷",@"速播专区",@"推理世界",@"正能量"];
    }
    return _items;
}

-(NSMutableArray *)dataArr
{
    if (_dataArr == nil) {
        self.dataArr = [NSMutableArray arrayWithCapacity:0];
    }
    return _dataArr;
}

-(NSMutableArray *)pageViews
{
    if (_pageViews == nil) {
        self.pageViews = [ NSMutableArray array];
    }
    return _pageViews;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    HACursor *cursor = [[HACursor alloc]init];
    cursor.frame = CGRectMake(0, 64, SCREEN_WIDTH, 45);
    cursor.titles = self.items;
    cursor.pageViews = [self createPageViews];
    //设置根滚动视图的高度
    cursor.rootScrollViewHeight = self.view.frame.size.height -109;
    //默认值是白色
    cursor.titleNormalColor = [UIColor whiteColor];
    //默认值是白色
    cursor.titleSelectedColor = [UIColor redColor];
    //是否显示排序按钮
    cursor.showSortbutton = YES;
    //默认的最小值是5，小于默认值的话按默认值设置
    cursor.minFontSize = 11;
    //默认的最大值是25，小于默认值的话按默认值设置，大于默认值按设置的值处理
    //cursor.maxFontSize = 30;
    //cursor.isGraduallyChangFont = NO;
    //在isGraduallyChangFont为NO的时候，isGraduallyChangColor不会有效果
    //cursor.isGraduallyChangColor = NO;
    [self.view addSubview:cursor];
    
}

- (NSMutableArray *)createPageViews{
    for (NSInteger i = 0; i < self.items.count; i++) {
        if (i == 0) {
            _bookRecomVC = [[BookRecommendTableViewController alloc]initWithStyle:(UITableViewStyleGrouped)];
            _bookRecomVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v2/category/recommends?categoryId=3&contentType=album&device=iPhone&scale=2&version=4.3.20";
            [self.pageViews addObject:_bookRecomVC.view];
        }
        else
        {
            [self dataWithIndex:i];
        }
    }
    return self.pageViews;
}



- (void)dataWithIndex:(long)index
{
    switch (index) {
        case 1:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E6%B5%AA%E6%BC%AB%E8%A8%80%E6%83%85";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 2:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E6%81%90%E6%80%96%E6%82%AC%E7%96%91";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 3:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E7%8E%84%E5%B9%BB%E5%A5%87%E5%B9%BB";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 4:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E5%8E%86%E5%8F%B2%E5%86%9B%E4%BA%8B";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 5:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E5%8F%A4%E8%A8%80%E5%AE%AB%E6%96%97";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 6:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E6%8E%A2%E6%A1%88%E6%8E%A8%E7%90%86";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 7:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E9%9D%92%E6%98%A5%E6%A0%A1%E5%9B%AD";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 8:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E9%83%BD%E5%B8%82%E7%94%9F%E6%B4%BB";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 9:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E7%A9%BF%E8%B6%8A%E6%9E%B6%E7%A9%BA";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 10:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E6%AD%A6%E4%BE%A0%E4%BB%99%E4%BE%A0";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 11:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E6%96%87%E5%AD%A6%E5%90%8D%E8%91%97";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 12:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E5%AE%98%E5%9C%BA%E5%95%86%E6%88%98";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 13:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E7%A7%91%E5%B9%BB%E6%B8%B8%E6%88%8F";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 14:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E8%AF%97%E8%AF%8D%E6%95%A3%E6%96%87";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 15:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E7%A4%BE%E7%A7%91%E7%BB%8F%E7%AE%A1";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 16:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=QQ%E9%98%85%E8%AF%BB";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 17:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E8%AF%BB%E5%AE%A2%E5%9B%BE%E4%B9%A6";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 18:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E6%9E%9C%E9%BA%A6%E6%96%87%E5%8C%96";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 19:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E4%B8%AD%E4%BF%A1%E5%87%BA%E7%89%88";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 20:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E5%8D%9A%E9%9B%86%E5%A4%A9%E5%8D%B7";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 21:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E9%80%9F%E6%92%AD%E4%B8%93%E5%8C%BA";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 22:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E6%8E%A8%E7%90%86%E4%B8%96%E7%95%8C";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 23:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=3&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E6%AD%A3%E8%83%BD%E9%87%8F%E6%9C%89%E5%A3%B0%E4%B9%A6";
            [self.pageViews addObject:_bookListVC.view];
            break;
        default:
            break;
            
    }

}
















- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
